package world;

import main.Main;

import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.util.glu.GLU.*;

public class Camera {

	float x, y, z;
	Player p;

	public Camera(Player p) {
		this.p = p;
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glOrtho(0, Main.WIDTH, Main.HEIGHT, 0, 1, -1);
		glMatrixMode(GL_MODELVIEW);
	}

	public void useView() {
		if (p.isAlive()) {
			x = p.getX() - Main.WIDTH / 2f;
			y = p.getY() - Main.HEIGHT / 2f;
		}

		glTranslatef(-x, -y, -z);
	}

	public void moveTo(float x, float y, float z) {
		this.x = x;
		this.y = y;
		this.z = z;
	}

	public void move(float dx, float dy, float dz) {
		x += dx;
		y += dy;
		z += dz;
		
		System.out.println("x: " + x + " y: " + y + " z: " + z);
	}

}
